function [fea,gnd] = loadCBCL(folder, output)
    face_folder = [folder '/face/'];
    non_face_folder = [folder '/non-face/'];
    
    face_file = dir([face_folder '*.pgm'] );
    for i=1:length(face_file) 
        X_train(i,:) = loadImage([face_folder face_file(i).name]);
        y_train(i) = 1;
    end

    face_file = dir([non_face_folder '*.pgm'] );
    for i=1:length(face_file) 
        X_test(i,:) = loadImage([non_face_folder face_file(i).name]);
        y_test(i) = 2;
    end
    fea = [X_train; X_test];
    gnd = [y_train(:); y_test(:)];
    save(output, 'fea', 'gnd');
end

function a = loadImage(filename)
    display([filename '']);
    a = imread(filename);
    a = histeq(a, 64);
    a = double(a(:)') / 255;
end
